﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="news_newsmanage.aspx.cs" Inherits="backmanage_newssystem_news_newsmanage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新闻管理</title>
    <script type="text/javascript" src="../js/jquery-1.6.1.js"></script>
	<link rel="stylesheet" href="../css/jquery.ui.select.css" />
	<script type="text/javascript" src="../external/jquery.bgiframe-2.1.2.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.core.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.widget.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.mouse.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.button.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.draggable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.position.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.resizable.js"></script> 
	<script type="text/javascript" src="../js/jquery.ui.dialog.js"></script> 
	<script type="text/javascript" src="../js/jquery.effects.core.js"></script>

	<link rel="stylesheet" href="../css/demos.css" />  
    <script type="text/javascript">
       $(function(){
              var mousetop,mouseleft;
              function Ishot(i)
              {
                var h=$("#selectlist option:selected").val();
                $.ajax({
                     async:false,
                     url:'../API/A_News.aspx',
                     type:'POST',
                     data:{edit:'ishot',id:i,ishot:h},
                     success:function(msg)
                     {
                        $("#"+i+" a.hot").text($("#selectlist").find("option:selected").text());
                     }
                })
              }
              function Classid(i)
              {
               var h=$("#classlist option:selected").val();
                $.ajax({
                     async:false,
                     url:'../API/A_News.aspx',
                     type:'POST',
                     data:{edit:'classid',id:i,classid:h},
                     success:function(msg)
                     {
                        $("#"+i+" a.classid").text($("#classlist").find("option:selected").text());
                     }
                })
              }
              function Title(i)
              {
                var h=$("#newstitle").val();
                $.ajax({
                     async:false,
                     url:'../API/A_News.aspx',
                     type:'POST',
                     data:{edit:'title',id:i,title:h},
                     success:function(msg)
                     {
                        $("#"+i+" a.text").text($("#newstitle").val());
                     }
                })
              }
              function selectEdit(edit,i)
              {
                switch(edit)
                {
                   case "hot":
                      {
                        Ishot(i);
                        break;
                      }
                   case "class":
                      {
                        Classid(i);
                        break;
                      }
                   case "title":
                      {
                        Title(i);
                        break;
                      }
                }
              }
	          $("#select-form").dialog("destory");
	          function dialogSet(e,w,i,d){
	          $(e).dialog({
	                       disabled:false,
	                       autoOpen:false,
	                       draggable:false,
	                       resizable:false,
	                       height:30,
	                       width:w,
	                       model:true,
	                       zIndex:1000,
	                       position:[mouseleft,mousetop],
	                       buttons:{
	                           "保存":function(){
	                                   selectEdit(d,i);
	                                   $(this).dialog("close");
	                           },
	                           "取消":function(){
	                                    $(this).dialog("close");
	                           }
	                       }
	          });
	          }
	          function dialogTextSet(e,i,d){
	          $(e).dialog({
	                       disabled:false,
	                       autoOpen:false,
	                       draggable:false,
	                       resizable:false,
	                       height:30,
	                       width:400,
	                       model:true,
	                       zIndex:1000,
	                       position:[mouseleft,mousetop],
	                       buttons:{
	                           "保存":function(){
	                                   selectEdit(d,i);
	                                   $(this).dialog("close");
	                           },
	                           "取消":function(){
	                                    $(this).dialog("close");
	                           }
	                       }
	          });
	          }
	          function ClassList()
	          {
	                  $.ajax({
	                          async:false,
	                          url:'../API/A_News.aspx',
	                          type:'POST',
	                          data:{edit:'class'},
	                          success:function(msg)
	                          {
	                             $("#class-form select").text("");
	                             $("#class-form select").append(msg);
	                          }
	                  })
	          }
	          function update(id)
              {
                  $.ajax({
                         url:'news_newsadd.aspx',
                         type:'POST',
                         data:{edit:'update',id:id},
                  });
                  var url='news_newsadd.aspx?edit=update&id='+id;
                  var top=(window.screen.availHeight-520)/2;
                  var left=(window.screen.availWidth-750)/2;
                  var setwindows="toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, copyhistory=0, width=750, height=520,top="+top+", left="+left+"";
                  window.open(url,"_blank",setwindows);
              }
              function NewsList()
              {
                      $.ajax({
                              async:false,
                              url:'../API/A_News.aspx',
                              type:'POST',
                              data:{edit:'list'},
                              success:function(msg)
                              {
                                $("#newList tbody").text("");
                                $("#newList tbody").append(msg);
                                $("#newList a.hot").click(function(){
	                              var p=$(this).parent();
	                              var t=$(this).parent().parent().attr("id");
	                              var v=$(this).attr("title");
	                              var poffset=p.offset();
	                              mousetop=poffset.top;
	                              mouseleft=poffset.left;
	                              dialogSet('#select-form',200,t,"hot");
	                              $('#select-form select').attr('value',v);
	                              $("#select-form").dialog("open");
	                          });
	                          $("#newList a.classid").click(function(){
	                              var p=$(this).parent();
	                              var t=$(this).parent().parent().attr("id");
	                              var v=$(this).attr("title");
	                              var poffset=p.offset();
	                              mousetop=poffset.top;
	                              mouseleft=poffset.left;
	                              dialogSet('#class-form',250,t,"class");
	                              $('#class-form select').attr('value',v);
	                              $("#class-form").dialog("open");
	                          });
	                          $("#newList a.text").click(function(){
	                              var p=$(this).parent();
	                              var t=$(this).parent().parent().attr("id");
	                              var v=$(this).text();
	                              var poffset=p.offset();
	                              mousetop=poffset.top;
	                              mouseleft=poffset.left;
	                              dialogTextSet('#text-form',t,"title");
	                              $("#newstitle").val(v);
	                              $("#text-form").dialog("open");
	                          });
	                          $("#newList a.edit").click(function(){
	                              var i=$(this).attr("title");
	                              update(i);
	                          });
                              }
                      });
              }
             
              function del()
              {
                    var c=$("#newList input:checked");
                    var b=new Array();
                    for(var i=0;i<c.length;i++)
                    {
                      b[i]=c[i].value;
                    }
                    if(b.length>0)
                    {
                      $.ajax({
                             async:false,
                             url:'../API/A_News.aspx',
                             type:'POST',
                             data:{edit:'del',newsid:b},
                             success:function(msg)
                             {
                                NewsList();
                                alert(msg);
                             }
                      });
                    }
                    else
                    {
                       alert("请先选择.");
                    }
              }
              function allyes()
              {
                    $("#newList input:checkbox").attr("checked",true);
              }
              function allno()
              {
                    $("#newList input:checkbox").removeAttr("checked");
              }
              
              $("#del").click(function(){
                          del();
              });
              $("#allyes").click(function(){
                          allyes();
              });
              $("#allno").click(function(){
                          allno();
              });
              $(document).ready(function(){NewsList();ClassList();});
       })
    </script>
    <style type="text/css">
	 table td{ height:30px; text-align:center}
	.select-form{ width:200px;height:30px;background:orange;text-align:left;font-family:宋体, Arial, Helvetica, sans-serif;font-size:12px;margin:0;padding:0;display:none}
	.select-form select{ height:20px;margin-top:0!important;margin-top:-10px;padding:0}
	.select-form option{ height:20px}
	.hot{ text-decoration:none;}
	.top{ text-decoration:none;}
	.text{ text-decoration:none;}
	.classid{ text-decoration:none;}
	.edit{ text-decoration:none;}
	</style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    新闻管理
    <table id="newList">
      <thead>
        <tr>
          <td style="width:30px">删除</td>
          <td style="width:50px">是否置顶</td>
          <td style="width:50px">图片新闻</td>
          <td style="width:60px">新闻类别</td>
          <td style="width:300px">新闻标题</td>
          <td style="width:100px">发布时间</td>
          <td style="width:30px">编辑</td>
        </tr>
      </thead>
      <tbody>
        
      </tbody>
      <tfoot>
         <tr>
           <td colspan="7" style=" text-align:left">一共0页 0条/页<input type="button" id="del" value="删除" /><input type="button" id="allyes" value="全选" /><input type="button" id="allno" value="全不选" /></td>
         </tr>
      </tfoot>
    </table>
    </div>
<div id="select-form" class="select-form">
<select id="selectlist">
 <option value="False">否</option>
 <option value="True">是</option>
</select>
</div>
<div id="text-form" class="select-form">
<input type="text" id="newstitle" style="width:240px; margin-top:-8px" />
</div>
<div id="class-form"  class="select-form">
<select id="classlist">
</select>
</div>
    </form>
</body>
</html>
